<template>
  <view>
    <scroll-view scroll-y="true" id="box" :style="{ height: boxHeight + 'px' }" @scrolltolower="getList">
      <view class="" style="margin: 20rpx 28rpx; background: #fff; border-radius: 20rpx" v-for="(i, k) in getarr" :key="k" @tap="uplood(i.doctor_id)">
        <view class="" style="display: flex; justify-content: space-between; padding: 44rpx 22rpx 11rpx 26rpx">
          <view class="" style="display: flex; align-items: flex-start">
            <view class="">
              <image :src="i.doctor_avatar" mode="aspectFill" style="width: 112rpx; height: 112rpx; border-radius: 50%"></image>
            </view>
            <view class="" style="padding-left: 18rpx">
              <view class="">
                <text style="font-size: 30rpx; font-weight: bold">{{ i.doctor_name }}</text>
                <text style="font-size: 26rpx; padding-left: 20rpx">{{ i.doctor_title }}</text>
              </view>
              <view
                class=""
                style="
                  font-size: 26rpx;
                  color: #666;
                  padding-top: 29rpx;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  -webkit-line-clamp: 1;
                  display: -webkit-box;
                  -webkit-box-orient: vertical;
                  width: 300rpx;
                "
              >
                按方开药
              </view>
            </view>
          </view>
          <view class="" style="font-size: 24rpx; color: #666">
            {{ i.extract_time ? i.extract_time : '' }}
          </view>
        </view>
        <view class="" style="font-size: 26rpx; text-align: right; padding-right: 19rpx; padding-bottom: 18rpx">
          <!-- 就诊人：{{list[current].patient_name}} -->
        </view>
      </view>
    </scroll-view>

    <u-modal v-model="show" :content="content" :show-cancel-button="true" @confirm="confirm"></u-modal>
  </view>
</template>

<script>
export default {
  name: '',
  data() {
    return {
      background: {
        background: '#fff'
      },
      scrollTop: 0,
      list: {},
      current: 0,
      type: null,
      page: 1,
      boxHeight: '',
      getarr: [],
      page1: 1,
      programme: [],
      show: false,
      content: '您还没有默认患者信息，请先录入'
    };
  },
  onReady() {
    this.box();
  },
  onShow() {
    this.getList(1);
  },
  //方法
  methods: {
    confirm() {
      uni.navigateTo({
        url: '/pages/user/data'
      });
    },
    box() {
      const query = uni.createSelectorQuery().in(this);
      query
        .select('#box')
        .boundingClientRect((data) => {
          this.boxHeight = this.screenHeight - data.top - 50;
        })
        .exec();
    },

    // joop() {
    //   uni.navigateTo({
    //     url: 'orderdetail'
    //   });
    // },
    oss() {
      this.api({
        url: '/api//index/getDefault',
        method: 'post'
      }).then((res) => {
        this.list = res.data;
      });
    },
    getList(e) {
      if (e == 1) {
        this.getarr = [];
        this.page = 1;
      }
      this.api({
        url: '/api//doctor/getList',
        method: 'post',
        data: {
          page: this.page
        }
      }).then((res) => {
        this.getarr = this.getarr.concat(res.data);
      });
    },
    uplood(e) {
      if (this.list.patient_id) {
        uni.navigateTo({
          url: '/news/uploading/uploading?id=' + e + '&pid=' + this.list.patient_id
        });
      } else {
        // uni.showToast({
        // 	title: '您还没有患者信息，请先录入',
        // 	icon: 'none'
        // })
        this.show = true;
      }
    }
  },
  //首页渲染
  onLoad(op) {
    this.oss();
  },
  //监听
  watch: {},
  //计算属性
  computed: {}
};
</script>

<style lang="scss" scoped>
.on {
  padding: 21rpx 53rpx 15rpx 25rpx;
  background: #f0f0f0;
  border-radius: 20rpx;
}

page {
  background: #f8f8f8;
}

.on1 {
  padding: 21rpx 53rpx 15rpx 25rpx;

  background: linear-gradient(0deg, #1a9eff 0%, #0fb8ff 100%);
  border-radius: 20rpx;
  color: #fff;
}

.gets {
  width: 92rpx;
  height: 40rpx;
  background: #e4f4ff;
  border-radius: 20rpx;
  text-align: center;
  line-height: 40rpx;
  font-size: 24rpx;
  color: #1a9eff;
}
</style>
